package com.kakavr.recharge.controller;

import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.kakavr.base.controller.BaseController;
import com.kakavr.result.MsgResult;
import com.kakavr.user.service.IUserRechargeService;
import com.kakavr.util.SessionUtils;
/**
 * 平台充值报表
 * @author gang.yang
 *
 */
@RestController
@RequestMapping("rechargeReport")
public class RechargeReportController extends BaseController {
	@Resource
	private IUserRechargeService userRechargeService;
	
	/**
	 * 充值记录
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "selectRechargeList", method = RequestMethod.GET)
	public Map<String, Object> selectRechargeList(HttpServletRequest request){
		String storeId = request.getParameter("storeId");
		String name = request.getParameter("storeName");
		Map<String, Object> map = this.initPaginationParams(request);
		map.put("begin", request.getParameter("begin"));
		map.put("end", request.getParameter("end"));
		if(StringUtils.isNotBlank(storeId)){
			map.put("storeId", storeId);
		}
		if(StringUtils.isNotBlank(name)){
			map.put("name", name);
		}
		map.put("partnerId", SessionUtils.getPartnerId());
		return MsgResult.okResultData(userRechargeService.selectRechargeByPage(map));
	}
	/**
	 * 充值警告
	 * 
	 * @param request
	 * @return
	 */
	@RequestMapping(value = "selectRechargeWarning", method = RequestMethod.GET)
	public Map<String, Object> selectRechargeWarning(HttpServletRequest request){
		String name = request.getParameter("storeName");
		Map<String, Object> map = this.initPaginationParams(request);
		map.put("partnerId", SessionUtils.getPartnerId());
		if(StringUtils.isNotBlank(name)){
			map.put("name", name);
		}
		return MsgResult.okResultData(userRechargeService.statisticsShopTotalCount(map));
	}
}
